/*
 * AnimationFabric.cpp
 *
 *  Created on: 05.01.2012
 *      Author: Kirill Blinov
 *      Copyright: LGPL
 */

#include "AnimationFabric.h"

/*
 * This function loads bones animation from .smd formatted file
 */
UINT
AnimationFabric::LoadAnimationFromFile( const std::string FileName )
{
	//AnimationsArray.push_back( new CMatrixAnimation( FileName ) ); //TODO Write loader for animation and physics configuration
	return 0;
}

bool
AnimationFabric::IsAnimationExist( std::string AnimationToReplace )
{
	return true;//( AnimationID < AnimationsArray.size() );
}

bool
AnimationFabric::RemoveAnimation( std::string AnimationToReplace )
{
	bool Result = IsAnimationExist( AnimationToReplace );

	//if (Result)
	//{
	//	AnimationsArray.erase( AnimationsArray.begin() + AnimationID );
	//}
	return Result;
}

void
AnimationFabric::ClearAllAnimations()
{
	AnimationsArray.clear();
}

/*
 * Creates bones or simple animation loaded from file.
 *
 * Parameters:
 *   AnimationID - ID of loaded animation
 *   Cyclic - restart an animation after it's finished
 */
CAnimationController*
AnimationFabric::CreateAnimationController( const UINT AnimationControllerID )
{
	IPhysicsObject NewPhysicsObject = PhysicObjectFabric::CreatePhysicsObject(  );
	CAnimationController* Animation = new CAnimationController( AnimationsArray[AnimationID],
			                                                    NewPhysicsObject);
    return Animation;
}

/*
 * Replace an animation AnimationToReplace in controller with another one with name NewAnimation
 */
bool
AnimationFabric::ReplaceAnimationInController( CAnimationController &Controller, std::string AnimationToReplace,
			                                   std::string NewAnimation )
{
	return false;
}

/*
 * Creates physical moving animation
 *
 * Parameters:
 * 	 Acceleration - acceleration
 * 	     acceleration < 0 for braking while speed > 0
 * 	 Direction - direction of the acceleration
 * 	 Duration - duration of the animation in seconds
 * 	     0 - for infinity acceleration to physical limitations
 * 	 Cyclic - restart an animation after it's finished
 */
IAnimationController*
AnimationFabric::CreateAnimation( const float Acceleration, glm::vec3 Direction, const UINT Duration, const bool Cyclic )
{

}

/*
 * Create physical rotation animation
 *
 * Parameters:
 *   Angle - angle of rotation
 *   Axis - axis around which an object will be rotated
 *   Cyclic - restart an animation after it's finished
 */
IAnimationController*
AnimationFabric::CreateAnimation( const float Angle, const glm::vec3 Axis, const bool Cyclic )
{

}
